<?php

namespace app\admin\controller;

use think\App;
use think\Request;
use think\facade\Session;
use app\admin\services\AgentService;

class Agent extends Authent
{
    public function __construct(Request $request = null, App $app = null)
    {
        parent::__construct($request, $app);
        $this->AgentService = new AgentService();
        global $authstate;
        if(isset($authstate['status']) && $authstate['status'] !=0 ){
            echo json_encode($authstate); die;
        }
    }



    /**
     * @return mixed
     * 首页
     */
    public function index()
    {
        
        return $this->fetch();
    }


    /**
     * @param 获取信息列表
     */
    public function seleclit(){
        $data = $this->AgentService->datalist();
        return json($data);
    }


    /**
     * @param 添加信息页面
     */
    public function addproble(){

        return $this->fetch();
    }


    /**
     * @param 添加信息
     */
    public function add(){
        $data = $this->AgentService->addlist();
        return json($data);
    }


    /**
     * @param 修改页面
     */
    public function edit(){
        $data = $this->AgentService->editdata();
        $this->assign("data",$data);
        return $this->fetch();
    }


    /**
     * @param 修改信息
     */
    public function editit(){
         $data = $this->AgentService->editlont();
        return json($data);
    }


    /**
     * @param 信息禁用、启用
     */
    public function jinyong(){
        $data = $this->AgentService->stustlod();
        return json($data);
    }


    /**
     * @param 删除信息
     */
    public function del(){
        $data = $this->AgentService->delete();
        return json($data);
    }

}